<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/header.ftl" />
</head>

<script>
    $(function () {
        //添加或修改按钮
        $(".inputBtn").click(function () {
            $("#editForm input").val("");
            $("#editForm img").attr("src","");
            var json = $(this).data("json");
            console.log(json);
            if (json) {
                $("#editForm input[name='id']").val(json.id);
                $("#editForm input[name='title']").val(json.title);
                $("#editForm input[name='subTitle']").val(json.subTitle);
                $("#editForm img[name='coverUrl']").attr("src",json.coverUrl);
                $("#editForm input[name='coverUrl']").val(json.coverUrl);
                $("#editForm select[name='place.id']").val(json.placeId);
                $("#editForm select[name='state']").val(json.state);
            }
            $("#strategyModel").modal("show");
        });
        //模态框的保存按钮
        $(".submitButton").click(function () {
            $("#editForm").ajaxSubmit(function () {
                reload();
            });
        });
    })
</script>
<body>
<!-- 模态框（Modal） -->
<div class="modal fade" id="strategyModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">新增大攻略</h4>
            </div>
            <#--游记内容-->
            <div class="modal-body">
                </div>
                    <form class="form-horizontal" action="/strategy/saveOrUpdate.do" method="post" id="editForm">
                        <input type="hidden" name="id">
                        <div class="form-group" >
                            <label for="name" class="col-sm-4 control-label">标题：</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="title">
                            </div>
                        </div>
                        <div class="form-group" >
                            <label for="name" class="col-sm-4 control-label">副标题：</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" name="subTitle">
                            </div>
                        </div>
                        <div class="form-group" >
                            <label for="name" class="col-sm-4 control-label">封面：</label>
                            <div class="col-sm-6">
                                <img name="coverUrl" width="100%">
                                <input type="file"  class="form-control" name="file">
                                <input type="hidden"  class="form-control" name="coverUrl">
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="sn" class="col-sm-4 control-label">所属地区：</label>
                            <div class="col-sm-6">
                                <select class="form-control" name="place.id">
                                    <#list regions as region>
                                        <option value="${region.id}">${region.name}</option>
                                    </#list>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="sn" class="col-sm-4 control-label">状态：</label>
                            <div class="col-sm-6">
                               <select class="form-control" name="state">
                                   <option value="0">普通</option>
                                   <option value="-1">拒绝</option>
                                   <option value="1">推荐</option>
                               </select>
                            </div>
                        </div>
                        <div style="text-align: center">
                            <a class="showTravel" target="_blank">
                                点击查看游记文章明细
                            </a>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-primary submitButton">保存</button>
                        </div>
                    </form>
                </div><!-- /.modal-content -->
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl" />
    <div class="row">
        <div class="col-sm-3">
            <#assign menu="strategy"/>
            <#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">大攻略管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/strategy/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}" placeholder="请输入标题">
                </div>
                <script>
                    <#-- 回显状态 -->
                </script>
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <button id="btn_query" class="btn btn-success" type="submit">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
                <button id="btn_add" class="btn btn-success inputBtn" type="button">
                    <span class="glyphicon glyphicon-plus"></span> 添加
                </button>
            </form>

            <table class="table table-striped table-hover" >
                <tr>
                    <th>编号</th>
                    <th>封面</th>
                    <th>攻略标题</th>
                    <th>副标题</th>
                    <th>所属地区</th>
                    <th>状态</th>
                    <th></th>
                </tr>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td><img src="${entity.coverUrl}" width="30px"> </td>
                        <td>${entity.title}</td>
                        <td>${entity.subTitle!}</td>
                        <td>${entity.place.name}</td>
                        <td>${entity.stateName}</td>
                        <td>

                            <a class="btn btn-info btn-xs btn-input inputBtn"  data-json='${entity.json}'>
                                <span class="glyphicon glyphicon-pencil"></span>修改
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl" />
        </div>
    </div>
</div>

<script>

</script>
</body>
</html>